<template>
  <div class="page has-navbar" v-nav="{ title: title, showBackButton: true, onBackButtonClick: back }">
    <div class="page-content text-center">
      <div class="index">
        <div v-for="(item, key) in newsList"  :key="key">
          <news-cell :newsObj="item" :key="key"></news-cell>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import NewsCell from './newsCell.vue'
  export default {
    data() {
      return {
        title: '新闻中心(mock数据)',
        newsList: []
      }
    },
    components: {
      NewsCell
    },
    created() {
      this.initData()
    },
    methods: {
      async initData() {
        let result  = await this.GLOBAL.api.newsService.list()
        this.newsList = result.data.articles
      },
      back() {
        $router.back('/')
      }
    }
  }
</script>
